<!DOCTYPE html>
<html lang="zh">
<head>
    <:include file="../../common/css.html" title="文本编辑"/>
</head>
<body class="pear-container">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    开发环境
                </div>
                <div class="layui-card-body">
                    Tinymce 文本编辑器
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-collapse">
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">显示代码</h2>
                    <div class="layui-colla-content">
                        <pre class="layui-code" lay-encode="true">
<link href="/assets/component/pear/css/pear.css" rel="stylesheet" />
 并
<script src="/assets/component/layui/layui.js"></script>
 并
<script src="/assets/component/pear/pear.js"></script>
                        </pre>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">富文本编辑器</div>
                <div class="layui-card-body">
                    <textarea name="" id="edit" cols="30" rows="10"></textarea>
                    <div class="layui-btn-group" style="margin-top: 10px">
                        <button class="pear-btn pear-btn-primary" lay-event="getContent">获取内容</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-collapse">
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">显示代码</h2>
                    <div class="layui-colla-content">
                        <pre class="layui-code" lay-encode="true">
layui.use(['tinymce'], function() {
    var tinymce = layui.tinymce

    var edit = tinymce.render({
        elem: "#edit",
        height: 400
    });

    edit.getContent()
});
                        </pre>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 依 赖 脚 本 -->
    <:include file="../../common/js.html" />
    <script>
        layui.use(['tinymce', 'util', 'layer','code','element'], function() {
            var tinymce = layui.tinymce
            var util = layui.util;

            layui.code({ encode: true  });

            var edit = tinymce.render({
                elem: "#edit",
                height: 400
            });

            util.event('lay-event', {
                getContent: function() {
                    console.log(edit.getContent())
                    layer.msg("展开控制台查看")
                }
            });
        });
    </script>
</body>
</html>
